import request from "@/request";
import { ldzzj_config } from "./default_config";
import {
  IDoctor,
  IHy,
  INum,
  IUser,
  IClinic,
  IClinicDetail,
  IDrug,
  ICodeRes,
  ICheckRes,
  IBookYyhRes,
  ZjjsIClinicDetail,
  IFyqd,
  IFyqdDetail,
  IArea,
  MiPre$0Type,
  IMzpbKs,
  IMzpbZs,
  IMzZq,
  DateItem,
  Doctor,
  hyType,
  ItemInfo,
  dzInfo,
  TableItem,
  IZyjyj,
  IHomePageTitle,
  ICardInfo, zyfyqdcxItemInfo, CyjsItemInfo,
} from "./typing";

/** 获取所有科室 */
export function getMzpbKs(query?: {}) {
  return request<IMzpbKs[]>({
    url: "/ldzzj/api/getMzpbKs",
    method: "post",
    data: {
      code: "his.mzpb_ks",
      data: { ...query },
    },
  });
}
/** 获取所有诊室 */
export function getMzpbZs(query?: {}) {
  return request<IMzpbZs[]>({
    url: "/ldzzj/api/getMzpbZs",
    method: "post",
    data: {
      code: "his.mzpb_zs",
      data: { ...query },
    },
  });
}

/** 获取所有诊区 */
export function getMzpbZq(query?: {}) {
  return request<IMzZq[]>({
    url: "/ldzzj/api/getMzpbZq",
    method: "post",
    data: {
      code: "his.mzpb_zq",
      data: { ...query },
    },
  });
}

/** 获取门诊下的所有医生 */
export function getMzpbYs(query?: {}) {
  return request<Doctor[]>({
    url: "/ldzzj/api/getMzpbYs",
    method: "post",
    data: {
      code: "his.mzpb_ys",
      data: { ...query },
    },
  });
}
/** 获取用户的门诊门诊缴费项目 */
export function getMzjf(query?: {}) {
  return request<ItemInfo[]>({
    url: "/ldzzj/api/getMzjf",
    method: "post",
    data: {
      code: "his.mzjf",
      data: { ...query },
    },
  });
}
/** 获取用户的出院结算缴费项目 */
export function getZyfyqdcx(query?: {}) {
  return request<zyfyqdcxItemInfo[]>({
    url: "/ldzzj/api/getzyfyqdcx",
    method: "post",
    data: {
      code: "his.zyfyqdcx",
      data: { ...query },
    },
  });
}
/** 获取用户的出院结算缴费项目 */
export function getCyjs(query?: {}) {
  return request<CyjsItemInfo[]>({
    url: "/ldzzj/api/getCyjs",
    method: "post",
    data: {
      code: "his.cyjs",
      data: { ...query },
    },
  });
}
/** 获取项目物价查询 */
export function getPrice(query?: {}) {
  return request<TableItem[]>({
    url: "/ldzzj/api/getPrice",
    method: "post",
    data: {
      code: "his.getPrice",
      data: { ...query },
    },
  });
}
/** 获取读卡类型 */
export function getDkType(query?: {}) {
  return request<ICardInfo[]>({
    url: "/ldzzj/api/getDkType",
    method: "post",
    data: {
      code: "his.getDkType",
      data: { ...query },
    },
  });
}
/** 获取省份信息 */
export function getsfxx(query?: {}) {
  return request<dzInfo[]>({
    url: "/ldzzj/api/getsfxx",
    method: "post",
    data: {
      code: "his.getsfxx",
      data: { ...query },
    },
  });
}
/** 获取市区信息 */
export function getsqxx(query?: {}) {
  return request<dzInfo[]>({
    url: "/ldzzj/api/getsqxx",
    method: "post",
    data: {
      code: "his.getsqxx",
      data: { ...query },
    },
  });
}
/** 获取市区信息 */
export function getxqxx(query?: {}) {
  return request<dzInfo[]>({
    url: "/ldzzj/api/getxqxx",
    method: "post",
    data: {
      code: "his.getxqxx",
      data: { ...query },
    },
  });
}
/** 获取街道乡镇信息 */
export function getjdxx(query?: {}) {
  return request<dzInfo[]>({
    url: "/ldzzj/api/getjdxx",
    method: "post",
    data: {
      code: "his.getjdxx",
      data: { ...query },
    },
  });
}
/** 获取可预约时间 */
export function getMzpdRq(query?: {}) {
  return request<DateItem[]>({
    url: "/ldzzj/api/getMzpdRq",
    method: "post",
    data: {
      code: "his.mzpb_rq",
      data: { ...query },
    },
  });
}

/** 根据开始时间结束时间获取未挂号指定号源 */
export function getHbByKssjJssj(query?: {}) {
  return request<INum>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.mzpb_hy_detail_hd",
      data: { ...query },
    },
  });
}
/** 根据日期医生和诊室获取预约号源 */
export function getMzpbYyHy(query?: {}) {
  return request<hyType[]>({
    url: "/ldzzj/api/getMzpbYyHy",
    method: "post",
    data: {
      code: "his.mzpb_yy_hy",
      data: { ...query },
    },
  });
}

/** 获取可预约时间 - 当天 */
export function getHyDetailDt(query?: {}) {
  return request<INum[]>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.mzpb_hy_detail_today",
      data: { ...query },
    },
  });
}

/** 获取可预约时间 */
export function getHyDetail(query?: {}) {
  return request<INum[]>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.mzpb_hy_detail",
      data: { ...query },
    },
  });
}

/** 预约 */
export function bookYyh(query?: {}) {
  return request<IBookYyhRes>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.book_yyh",
      data: { ...query },
    },
  });
}

/** 绑定用户信息 */
export function patInfo(query?: {}) {
  return request<IUser>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.pat_info_zzj",
      data: { ...query },
    },
  });
}

/** 绑定手机号 */
export function patInfoMobile(query?: {}) {
  return request<IUser>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.pat_info",
      data: { ...query },
    },
  });
}

/** 获取用户缴费列表 */
export function getClinicList(query?: {}) {
  return request<IClinic[]>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.query_mzfee_jzlsh",
      data: { ...query },
    },
  });
}

/** 获取用户缴费列表 */
export function getClinicDetail(query?: {}) {
  return request<IClinicDetail[]>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.query_mzfee_detail",
      data: { ...query },
    },
  });
}

/** 获取用户缴费列表 */
export function getZjjsClinicDetail(query?: {}) {
  return request<ZjjsIClinicDetail>({
    url: ldzzj_config.ldzzj_zjjs_pre_pay,
    method: "post",
    data: {
      ...query,
    },
  });
}

/** 获取费用查询列表 */
export function getHospList(query?: {}) {
  return request<IDrug[]>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.v_hosp_directory",
      data: { ...query },
    },
  });
}

/** 获取医保结算信息 */
export function zjjsMiInfo(query?: { payType: "1" | "2" }) {
  return request<ICodeRes>({
    url: ldzzj_config.ldzzj_zjjs_mi_info,
    method: "post",
    data: {
      ...query,
    },
  });
}

/** 门诊缴费获取支付二维码 */
export function zjjsOutPatPay(query?: {}) {
  return request<ICodeRes>({
    url: ldzzj_config.ldzzj_zjjs_smzf,
    method: "post",
    data: {
      code: "pay",
      data: { ...query },
    },
  });
}

/** 验证用户是否支付成功 */
export function zjjsOutPatCheck(query?: {}) {
  return request<ICheckRes>({
    url: ldzzj_config.ldzzj_zjjs_smzf,
    method: "post",
    data: {
      code: "check",
      data: { ...query },
    },
  });
}

/** 取消支付 */
export function zjjsOutPatCancel(query?: {}) {
  return request<ICheckRes>({
    url: ldzzj_config.ldzzj_zjjs_smzf,
    method: "post",
    data: {
      code: "cancel",
      data: { ...query },
    },
  });
}

/** 验证用户是否支付成功 */
export function outPatCheck(query?: {}) {
  return request<ICheckRes>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.outpat_pay_check",
      data: { ...query },
    },
  });
}

/** 取消支付 */
export function outPatCancel(query?: {}) {
  return request<ICheckRes>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.outpat_pay_cancel",
      data: { ...query },
    },
  });
}

export function outPatM1Cancel(query?: {}) {
  return request<ICheckRes>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.outpat_register_m1_cancel",
      data: { ...query },
    },
  });
}

export function outPatM1Cancel_MI(query?: {}) {
  return request<ICheckRes>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.outpat_register_m1_mi_cancel",
      data: { ...query },
    },
  });
}

/** 预约挂号获取支付二维码 */
export function yyghPay(query?: {}) {
  return request<ICodeRes>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.yygh_pay",
      data: { ...query },
    },
  });
}

/** 验证用户是否支付成功 */
export function yyghPayCheck(query?: {}) {
  return request<ICheckRes>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.yygh_pay_check",
      data: { ...query },
    },
  });
}

/** 当天挂号收费 */
export function m1PayCheck(query?: {}) {
  return request<ICheckRes>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.outpat_register_m1_check",
      data: { ...query },
    },
  });
}

/** 当天挂号收费 */
export function m1PayCheck_MI(query?: {}) {
  return request<ICheckRes>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.outpat_register_m1_mi_check",
      data: { ...query },
    },
  });
}


/** 挂号-先缴费后门诊 */
export function outPatRegisterM1(query?: {}) {
  return request<IBookYyhRes>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.outpat_register_m1",
      data: { ...query },
    },
  });
}

/** 医保挂号-先缴费后门诊 */
export function outPatRegisterM1_MI(query?: {}) {
  return request<MiPre$0Type>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.outpat_register_m1_mi_pre",
      data: { ...query },
    },
  });
}


/** 挂号-先门诊后缴费 */
export function outPatRegisterM2(query?: {}) {
  return request<{
    jzlsh: string;
    print_json: any;
    zxt_id: string;
  }>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.outpat_register_m2",
      data: { ...query },
    },
  });
}

/** 获取诊疗和付费先后顺序 */
export function outPatRegisterZxt(query?: {}) {
  return request<{ zxt_id: "M1" | "M2" }>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.outpat_register_zxt",
      data: { ...query },
    },
  });
}

/** 获取住院预缴金详情 */
export function getZYYJJDetail(query?: {}) {
  return request<IZyjyj>({
    url: "/ldzzj/api/getZYYJJDetail",
    method: "post",
    data: {
      code: "his.inpat_yjk_detail",
      data: { ...query },
    },
  });
}
/** 住院预交金 */
export function zyyjPay(query?: {}) {
  return request<any[]>({
    url: "/ldzzj/api/zyyjPay",
    method: "post",
    data: {
      code: "his.zyyjPay",
      data: { ...query },
    },
  });
}
/** 住院预缴款获取支付二维码 */
export function InpatYjk(query?: {}) {
  return request<any>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.inpat_yjk",
      data: { ...query },
    },
  });
}

/** 验证用户是否支付成功 */
export function InpatYjkCheck(query?: {}) {
  return request<any>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.inpat_yjk_check",
      data: { ...query },
    },
  });
}
// 获取homePage title
export function getTitle(query?: {}) {
  return request<IHomePageTitle[]>({
    url: "/ldzzj/api/getTitle",
    method: "post",
    data: {
      code: "his.home_page_title",
      data: { ...query },
    },
  });
}
/** 取消支付 */
export function InpatYjkCancel(query?: {}) {
  return request<any>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.inpat_yjk_cancel",
      data: { ...query },
    },
  });
}

/** 查询费用清单列表 */
export function InpatFyqdQuery(query?: {}) {
  return request<IFyqd[]>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.inpat_fyqd_query",
      data: { ...query },
    },
  });
}

/** 查询费用清单详情 */
export function InpatFyqdDetail(query?: {}) {
  return request<IFyqdDetail[]>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.inpat_fyqd_detail",
      data: { ...query },
    },
  });
}


/** 获取省市区 */
export function getArea(query?: {}) {
  return request<IArea[]>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "env.area",
      data: { ...query },
    },
  });
}

/** 获取省市区 */
export function yyqh_list(query?: {}) {
  return request<any[]>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.yyqh_list",
      data: { ...query },
    },
  });
}

/** 预约订单验证 */
export function yyqh_solve_qh(query?: {}) {
  return request<any[]>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.yyqh_solve_qh",
      data: { ...query },
    },
  });
}

/** 获取预约取号数据 */
export function getyyqhlist(query?: {}) {
  return request<any[]>({
    url: "/ldzzj/api/getyyqhList",
    method: "post",
    data: {
      code: "his.getyyqhList",
      data: { ...query },
    },
  });
}
/* 取号预结算 */
export function yjs(query?: {}) {
  return request<any>({
    url: "/ldzzj/api/yjs",
    method: "post",
    data: {
      code: "his.yjs",
      data: { ...query },
    },
  });
}
/* 门诊缴费预结算 */
export function mzjfyjs(query?: {}) {
  return request<any>({
    url: "/ldzzj/api/mzjfyjs",
    method: "post",
    data: {
      code: "his.mzjfyjs",
      data: { ...query },
    },
  });
}
/* 挂号预结算 */
export function ghyjs(query?: {}) {
  return request<any>({
    url: "/ldzzj/api/ghyjs",
    method: "post",
    data: {
      code: "his.ghyjs",
      data: { ...query },
    },
  });
}
/* 校验结算 */
export function jyjs(query?: {}) {
  return request<any>({
    url: "/ldzzj/api/jyjs",
    method: "post",
    data: {
      code: "his.jyjs",
      data: { ...query },
    },
  });
}


/* 取消结算 */
export function qxjs(query?: {}) {
  return request<any>({
    url: "/ldzzj/api/qxjs",
    method: "post",
    data: {
      code: "his.qxjs",
      data: { ...query },
    },
  });
}
/** 取号/取消预约 true取号，false取消预约 */
export function quhao(query?: {}) {
  return request<any[]>({
    url: "/ldzzj/api/quhao",
    method: "post",
    data: {
      code: "his.quhao",
      data: { ...query },
    },
  });
}
/** 门诊缴费pay */
export function mzjfPay(query?: {}) {
  return request<any[]>({
    url: "/ldzzj/api/mzjfPay",
    method: "post",
    data: {
      code: "his.mzjfPay",
      data: { ...query },
    },
  });
}
/** 挂号 */
export function gh(query?: {}) {
  return request<any[]>({
    url: "/ldzzj/api/gh",
    method: "post",
    data: {
      code: "his.gh",
      data: { ...query },
    },
  });
}
/** 获取化验单数据 */
export function gethyd(query?: {}) {
  return request<any[]>({
    url: "/ldzzj/api/gethyd",
    method: "post",
    data: {
      code: "his.gethyd",
      data: { ...query },
    },
  });
}
/** 打印化验单 */
export function dyhyd(query?: {}) {
  return request<any[]>({
    url: "/ldzzj/api/dyhyd",
    method: "post",
    data: {
      code: "his.dyhyd",
      data: { ...query },
    },
  });
}

/** lis打印数据校验 */
export function lis_print_check(query?: {}) {
  return request<any[]>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.lis_print_check",
      data: { ...query },
    },
  });
}


/** 化验单打印获取新的就诊卡号 */
export function hyddy_jzk_new(query?: {}) {
  return request<{jzkh:string}>({
    url: "/ldzzj/ldzzj/api",
    method: "post",
    data: {
      code: "his.hyddy_jzk_new",
      data: { ...query },
    },
  });
}

/** 签到接口 */
export function outpatSign(query?: {}) {
  return request<IUser>({
    url: "/ld/common/v1/diagqueue?method=outpat_sign",
    method: "get",
    params:query
  });
}
